package 第一章基础算法.双指针.id2816判断子序列;

import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for(int i = 0;i<n;i++){
            a[i] = scanner.nextInt();
        }
        for(int i = 0;i<m;i++){
            b[i] = scanner.nextInt();
        }
        int p1 = 0;
        int p2 = 0;
        while (p2 < m && p1 < n){
            if(b[p2] == a[p1])p1++;
            p2++;
        }
        if(p1 == n)System.out.println("Yes");
        else System.out.println("No");
    }
}
